package logic

import (
	"context"
	"shop_srv/shopsrvclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserRestLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserRestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserRestLogic {
	return &UserRestLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserRestLogic) UserRest(req *types.UserRestRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	rest, err := l.svcCtx.ShopSrv.UserRest(l.ctx, &shopsrvclient.UserRestRequest{
		Password: req.Password,
		Account:  req.Account,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "注册成功",
		Data:    rest,
	}, nil
}
